<template>
  <div class='container'>
    <div class='mycard'>
      <div class='weui-cell'>
        <div class='weui-cell__hd'>
          <div class='tx'>
            <div class="Avatar" >
                <img src="/static/images/tx.png" alt="" class="avatar" mode="aspectFill" v-if="userINfo.avatar==''">
                <img :src="userINfo.avatar" alt="" class="avatar" mode="aspectFill" v-else>
            </div>
          </div>
        </div>
        <div class='weui-cell__bd'>
          <div class='myList'>
            <div class='myListItem'>
              <div class='shu'>
                <span v-if="userINfo.fans==null">0</span>
                <span v-else>{{userINfo.fans}}</span>
              </div>
              <div class='zi'>粉丝</div>
            </div>
            <div class='myListItem'>
              <div class='shu'>
                <span v-if="userINfo.guanzhu==null">0</span>
                <span v-else>{{userINfo.guanzhu}}</span>
              </div>
              <div class='zi'>关注</div>
            </div>
            <div class='myListItem'>
              <div class='shu'>
                <span v-if="userINfo.zan==null">0</span>
                <span v-else>{{userINfo.zan}}</span>
              </div>
              <div class='zi'>获赞</div>
            </div>
            <div class='myListItem'>
              <div class='shu'>
                <span v-if="userINfo.jifen==null">0</span>
                <span v-else>{{userINfo.jifen}}</span>
              </div>
              <div class='zi'>积分</div>
            </div>
          </div>
          <div class='userName'>
            <div class="weui-cell__bd"></div>
            <div class='weui-cell__ft'>
               <chatBtn :userInfo="userINfo"/>
            </div>
            <div class='weui-cell__ft'>
              <Follow :info="userINfo" :userId="userINfo.id"></Follow>
            </div>
          </div>
        </div>
      </div>
      <div class='weui-cell'>
        <div class='weui-cell__bd'>
          <div class='userINfo'>
            <img src='/static/images/renz.png' style='width:12px;height:11px;margin-right:10px;' /> 认证：
            <span v-if="userINfo.is_auth==2">认证失败</span>
            <span v-if="userINfo.is_auth==1">审核中</span>
            <span v-if="userINfo.is_auth==0">未认证</span>
            <span v-if="userINfo.role==1&&userINfo.is_auth==3">家长</span>
            <span v-if="userINfo.role==2&&userINfo.is_auth==3">优秀老师</span>
            <span v-if="userINfo.role==3&&userINfo.is_auth==3">教育公司</span>
            <span v-if="userINfo.role==4&&userINfo.is_auth==3">教育媒体</span>
            <span v-if="userINfo.role==5&&userINfo.is_auth==3">其他</span>
            <span v-if="userINfo.role==6&&userINfo.is_auth==3">全日制学校</span>
          </div>
          <div class='userINfo'>
            <img src='/static/images/myadr.png' style='width:12px;height:12px;margin-right:10px;' />
            <span v-if="!userINfo.area">位置：该用户暂未填写地址</span>
            <span v-else>位置：{{userINfo.area}}</span>
          </div>
          <div class='userINfo'>
            <img src='/static/images/info.png' style='width:12px;height:12px;margin-right:10px;' />
            <span v-if="!userINfo.brief">简介：该用户暂未填写简介</span>
            <span v-else>简介：{{userINfo.brief}}</span>
          </div>
        </div>
        <div class='weui-cell__ft share' @click="shareShow">
           <van-icon class="share" name="share" size="23px"/>
          <p>名片分享</p>
        </div>
      </div>
    </div>
    <div class="line"></div>
    <div class="allNav">
      <van-tabs @change="onClick" :active="active">
        <van-tab v-for="(item,index) in allNav" :title="item.name" :key="index">
        </van-tab>
      </van-tabs>
      <div class="que" v-show="isempty">
        <img src="/static/images/que/no_conten@2x.png" alt="">
      </div>
      <div class="listitem" v-for="(item, idx) in list" :key="idx">
        <div v-if="item.article_type=='3'">
          <!-- 悬赏问答-->
          <questionlist :queList="item" type="2" isother="true"></questionlist>
        </div>
        <div v-if="item.article_type=='4'" style="padding-top:10px;">
          <!-- 视频-->
          <videoList :videoList="item" type="2"></videoList>
        </div>
        <div v-if="item.article_type=='1'">
          <!--  专栏-->
          <special :specialList="item" type="2" :isz="1"></special>
        </div>
        <div v-if="item.article_type=='2'">
          <!--  教育资讯-->
          <special :specialList="item" type="2" :isz="0"></special>
        </div>
        <div class="weui-cell faTime" v-if="item.article_type!='3'">
            <div class="weui-cell__bd">{{item.created_at}}</div>
            <div class="weui-cell__ft">
                <report :info="item" type="1" model="1"></report>
            </div>
        </div>
      </div>
      
        <div class="flexc">
          <van-loading type="spinner" v-if="load" />
          <span v-if="nomore" style="font-size:12px;color:#c9c9c9">我是有底线的</span>
        </div>
    </div>
    <div class="kong"></div>
    
    <div class="footer " v-if="userINfo.is_auth==3">
      <div class="weui-cell__bd" @click="toInfo(1)">
        <img src="/static/images/ic_introduction_mechanism@2x.png" alt="" style="height:13px;width:11px"> 个人资料
      </div>
      <div class="weui-cell__bd" v-if="userINfo.role==3&&userINfo.is_auth==3" @click="toInfo(2)">
        <img src="/static/images/ic_institutional_curriculum@2x.png" alt="" style="height:13px;width:17px"> 机构课程
      </div>
    </div>
    <saveimg :info="userINfo" :qrcode="qrcode" v-if="share" @closeShow="closeShow"  @saveImg="sImg"></saveimg>
  </div>
</template>
<script>
import Follow from "@/components/follow"
import special from "@/components/special"
import videoList from "@/components/videoList"
import questionlist from "@/components/questionlist"
import report from "@/components/report"
import operate from "@/components/operate"
import saveimg from "@/components/saveimg"
import avatar from "@/components/avatar"
import chatBtn from "@/components/chatBtn"

import {code} from "@/api/operate"
import {
    otherINfo
} from "@/api/other"
import {
    otherList
} from "@/api/other"
export default {
    components: {
        avatar,
        Follow,
        special,
        videoList,
        questionlist,
        saveimg,
        report,
        chatBtn
    },
    data() {
        return {
            isempty: false,
            userINfo: {},
            active: "0",
            allNav: [{
                    name: "全部",
                    id: "99"
                },
                {
                    name: "专栏",
                    id: "1"
                },
                {
                    name: "资讯",
                    id: "2"
                },
                {
                    name: "问答",
                    id: "3"
                },
                {
                    name: "小视频",
                    id: "4"
                },

            ],
            imgurl: this.$URL.imgurl,
            list: [],
            status: 99,
            load: false,
            nomore: false,
            user_id: "",
            share: false,
            qrcode:"",
            ta_uid:0,
            page:1,
            last_page:0
        }
    },
    methods: {
      chatTo(item) {
          wx.navigateTo({
              url: '/pages/chatOnLine/main?info=' + JSON.stringify(item)
          })
      },
        shareShow(){
            let data={};
            data.user_id=this.user_id;
            data.share_type=1;
            code(data).then(res=>{
                this.qrcode=res.data;
            }).then(res=>{
                this.share = true;
            })  
        },
        closeShow(){
            this.share=false
        },
        sImg(data){
            this.closeShow()
            this.share=false;
        },
        toInfo(type) {
          if(type==1){
              mpvue.navigateTo({
                url: '../otherinfo/main?id=' + this.ta_uid
            })   
          }else{
             mpvue.navigateTo({
                url: '../organClass/main?id=' + this.ta_uid
            })  
          }
            
        },
        getInfo() {
            let data = {};
            data.ta_uid = this.ta_uid;
            data.user_id = this.user_id;
            otherINfo(data).then(res => {
                this.userINfo = res.data
            })
        },
        getlist() {
            this.isempty = false
            let data = {};
            data.type = this.status;
            data.ta_uid = this.ta_uid;
            data.page = this.page;
            otherList(data).then(res => {
                if(res.code==200){
                    this.last_page = res.data.last_page;
                    if (this.page == 1) {
                        this.list = res.data.data
                    } else {
                        this.list = this.list.concat(res.data.data)
                    }
                }else if(res.code==201){
                  this.isempty = true
                }
                
            }).catch(err => {
                this.isempty = true
                this.list = []
            })
        },
        onClick(e) {
            // console.log(e)
            this.page = 1;
            this.active = e.target.index;
            if (e.target.index == 0) return this.status = 99, this.getlist();
            this.status = e.target.index
            this.getlist();
        },
    },
    created() {

    },
    onReachBottom: function () {
        this.nomore = false
        this.load = true
        setTimeout(() => {
            this.page += 1
            if (this.page > this.last_page) return this.nomore = true,this.load=false
            this.getlist()
        },1500)

    },
    onLoad(options) {
        Object.assign(this.$data, this.$options.data())
        this.ta_uid = options.id;
        this.user_id = wx.getStorageSync("user_info").id;
        this.getInfo()
        this.getlist()
    },
    onUnload(){
        console.log('离开页面')
    },
    onPullDownRefresh() {
      wx.showNavigationBarLoading(); //在标题栏中显示加载
      setTimeout(() => {
        this.getlist();
        wx.hideNavigationBarLoading(); //完成停止加载
        wx.stopPullDownRefresh(); //停止下拉刷新
      }, 1500);
  },
}
</script>

<style lang="scss">
.que {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 60px;

    img {
        height: 170px;
        width: 228px;
    }
}
.flexc {
        display: flex;
        justify-content: center;
    }

.allNav {
    .van-tab {
        font-size: 14px;
        color: #666;
    }

    .van-tab--active {
        color: #333;
        font-size: 15px;
    }

    .van-tabs__line {
        background-color: #1A84FB;
    }

    .van-tabs__wrap--scrollable .van-tab {
        -webkit-flex: 0 0 16.28% !important;
        flex: 0 0 16.28% !important;
    }
}
.listitem{
    position:relative;
    .special{
        border-bottom:0;
    }
    .videolist{
        border-bottom:0;
    }
    .queList{
        border-bottom:0;
        .reportIcon{
            margin-top:10px;
            float:right;
        }
    }
    &::after{
        position:absolute;
        left:15px;
        right:15px;
        content:"";
        bottom:0;
        border-bottom:1px solid #ddd;
    }
}
</style>

<style lang="scss" >
.whiteLIne{
  height:10px;
}
.mycard{
  .share{
    text-align: center;
    font-size:11px;
    font-weight:500;
    color:rgba(26,132,251,1);
    line-height:18px;
  }
  .tx{
    width:84px;
    height:84px;
    border-radius:50%;
    position: relative;
    .Avatar{
        width:84px;
        height:84px;
        .avatar{
            display: block;
            width:84px;
            height:84px;
            border-radius:50%;
            border:1px solid rgba(26,132,251,1);
        }
        .grade{
            width:46rpx;
            height:46rpx;
        }
    }
  }
  .myList{
    display: flex;
  }
  .myListItem{
    -webkit-box-flex:1;
    -webkit-flex:1;
    flex:1;
    text-align: center;
    line-height: 1;
    .shu{
      font-size:17px;
      font-weight:bold;
      color:rgba(51,51,51,1);
    }
    .zi{
      font-size:12px;
      font-weight:500;
      color:rgba(102,102,102,1);
      margin-top: 7px;
    }
  }
  .userName{
    display: flex;
    padding-left: 20px;
    margin-top: 13px;
    .btn{
        width:71px;
        border:1px solid rgba(102,102,102,1);
        border-radius:5px;
        text-align: center;
        line-height: 27px;
        font-size:14px;
        font-weight:500;
        color:rgba(51,51,51,1);
        margin-right: 20px;
    }
  }
  .userINfo{
    font-size:12px;
    font-weight:500;
    color:rgba(102,102,102,1);
    line-height: 1;
    margin-bottom: 10px;
    display:-webkit-box;
    display:-webkit-flex;
    display:flex;
    -webkit-box-align:center;
    -webkit-align-items:center;
    align-items:center;
  }
}    
li{
  position: relative;
  &::after{
     position: absolute;
     left:15px;
     right:15px;
     content:"";
     bottom:0;
     border-bottom:1px solid #ddd;
  }
}
.faTime{
    font-size:12px;
    font-weight:500;
    color:rgba(102,102,102,1);
}
.kong{
   height: 49px;
}
.footer{
    width:375px;
    height:49px;
    background:rgba(255,255,255,1);
    box-shadow:0px 0px 0px 0px rgba(221,221,221,1);
    text-align: center;
    line-height: 49px;
    font-size:14px;
    font-weight:500;
    color:rgba(51,51,51,1);
    position: fixed;
    bottom: 0;
    left: 0;
    display: flex;
    border-top: 1px solid #ddd;
    img{
        vertical-align: middle;
    }
}
</style>
